package cn.whr.server1.controller;

import cn.whr.server1.entity.ResponseDTO;
import cn.whr.server1.entity.UserEntity;
import cn.whr.server1.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;

    @RequestMapping("/registration")
    public ResponseDTO Registration(UserEntity user) {// 假设用户名,密码,电话号码格式在前端已检验
        return userService.Registration(user);
    }

    @RequestMapping("/RegistrationEnd")
    public ResponseDTO RegistrationEnd(UserEntity user, String code) throws UnsupportedEncodingException, NoSuchAlgorithmException {
        return userService.RegistrationEnd(user, code);
    }

    @RequestMapping("/login")
    public ResponseDTO login(UserEntity user) throws UnsupportedEncodingException, NoSuchAlgorithmException {
        return userService.login(user);
    }

}
